package dto

import (
	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type JenkinsGetPageReq struct {
	dto.Pagination `search:"-"`
	JenkinsOrder
}

type JenkinsOrder struct {
	Id        string `form:"idOrder"  search:"type:order;column:id;table:jenkins"`
	Name      string `form:"nameOrder"  search:"type:order;column:name;table:jenkins"`
	Username  string `form:"usernameOrder"  search:"type:order;column:username;table:jenkins"`
	Password  string `form:"passwordOrder"  search:"type:order;column:password;table:jenkins"`
	Address   string `form:"addressOrder"  search:"type:order;column:address;table:jenkins"`
	Remark    string `form:"remarkOrder"  search:"type:order;column:remark;table:jenkins"`
	CreatedAt string `form:"createdAtOrder"  search:"type:order;column:created_at;table:jenkins"`
	UpdatedAt string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:jenkins"`
	DeletedAt string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:jenkins"`
	CreateBy  string `form:"createByOrder"  search:"type:order;column:create_by;table:jenkins"`
	UpdateBy  string `form:"updateByOrder"  search:"type:order;column:update_by;table:jenkins"`
}

func (m *JenkinsGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type JenkinsInsertReq struct {
	Id       int    `json:"-" comment:"编码"` // 编码
	Name     string `json:"name" comment:"名称"`
	Username string `json:"username" comment:"jenkins 用户名称"`
	Password string `json:"password" comment:"jenkins 密码"`
	Address  string `json:"address" comment:"jenkins 地址"`
	Remark   string `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *JenkinsInsertReq) Generate(model *models.Jenkins) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Name = s.Name
	model.Username = s.Username
	model.Password = s.Password
	model.Address = s.Address
	model.Remark = s.Remark
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *JenkinsInsertReq) GetId() interface{} {
	return s.Id
}

type JenkinsUpdateReq struct {
	Id       int    `uri:"id" comment:"编码"` // 编码
	Name     string `json:"name" comment:"名称"`
	Username string `json:"username" comment:"jenkins 用户名称"`
	Password string `json:"password" comment:"jenkins 密码"`
	Address  string `json:"address" comment:"jenkins 地址"`
	Remark   string `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *JenkinsUpdateReq) Generate(model *models.Jenkins) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Name = s.Name
	model.Username = s.Username
	model.Password = s.Password
	model.Address = s.Address
	model.Remark = s.Remark
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *JenkinsUpdateReq) GetId() interface{} {
	return s.Id
}

// JenkinsGetReq 功能获取请求参数
type JenkinsGetReq struct {
	Id int `uri:"id"`
}

func (s *JenkinsGetReq) GetId() interface{} {
	return s.Id
}

// JenkinsDeleteReq 功能删除请求参数
type JenkinsDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *JenkinsDeleteReq) GetId() interface{} {
	return s.Ids
}
